package dubbo.test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import javax.crypto.spec.IvParameterSpec;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.shundr.common.utils.ByteUtils;
import com.shundr.common.utils.rsa.AESCodec;
import com.shundr.common.utils.rsa.DES;


public class encodeMyTest {
	
	private static final Log log = LogFactory.getLog(encodeMyTest.class);

	public static void main(String[] args) throws Exception {
		InputStream is;
		try {
			/*****/
			is = new FileInputStream(new File("F:\\OpenProj\\smart_monitor_dubbo_service\\monitor-service-socket\\target\\classes\\org\\springframework\\asm\\ClassReader.class"));
			byte[] bytes = FileUtils.getBytes(is);

			bytes =  com.shundr.common.utils.rsa.DES.encryptECB(bytes, "as*B%$bg".getBytes(), (byte)0x7F);
			
			bytes = ByteUtils.connect(new byte[]{0x7D,0x7D,0x7D,0x7D,0x7D,0x7D}, bytes);
			FileUtils.writeByteArrayToFile(new File("D:\\ClassReader.class"), bytes);
			
			/*****/
			is = new FileInputStream(new File("F:\\OpenProj\\smart_monitor_dubbo_service\\monitor-service-socket\\target\\classes\\com\\xyzn\\config\\MyDecoder.class"));
			bytes = FileUtils.getBytes(is);

			bytes =  com.shundr.common.utils.rsa.DES.encryptECB(bytes, "as*B%$bg".getBytes(), (byte)0x7F);
			
			bytes = ByteUtils.connect(new byte[]{0x7D,0x7D,0x7D,0x7D,0x7D,0x7D}, bytes);
			FileUtils.writeByteArrayToFile(new File("D:\\MyDecoder.class"), bytes);
		} catch (FileNotFoundException e) {
			
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		} catch (IOException e) {
			
			// TODO Auto-generated catch block
			e.printStackTrace();
			
		}
		
		
		log.info("over");
	}
}